var gulp = require('gulp');
var less = require('gulp-less');
var browserSync = require('browser-sync').create();
var reload  = browserSync.reload;
var fs = require("fs");

gulp.task('server',['less'], function() {
  browserSync.init({
    server: {
        baseDir: "./src"
    }
  });
  gulp.watch("src/less/*.less",['less']);
  gulp.watch(["src/*.html","src/js/**"]).on('change',reload);
});

gulp.task('less', function () {
  gulp.src(['./src/less/main.less'])
    .pipe(less())
    .pipe(gulp.dest('./src/css/'))
    .pipe(browserSync.stream());
});

gulp.task('default', ['server']);